package cn.fl.carloan.controller;

import java.util.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import cmm.user.facade.system.dto.LoginCacheDTO;
import cmm.user.facade.system.dto.SysUsrFunAuthRDTO;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.fl.carloan.service.IOdrCompInfoService;
import cn.fl.carloan.service.IOdrPhoneNoteWebService;
import cn.fl.carloan.vo.OdrCompInfoVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.lionbridge.center.dto.UserDTO;
import fl.carloan.facade.carloan.api.IOdrPhoneNoteWebApiService;
import fl.carloan.facade.carloan.condition.*;
import fl.carloan.facade.carloan.dto.OdrCompInfoDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSONObject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;

/**
 * @Description: 车抵贷公司信息表 控制层
 */
@Controller
@RequestMapping("/carloan/odrcompinfo")
public class OdrCompInfoController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(OdrCompInfoController.class);

    /**
     * OdrCompInfo 服务层BEAN
     */
    /**
     * OdrCompInfo 服务层BEAN
     */
    @Autowired
    private IOdrCompInfoService odrCompInfoService;

    @Autowired
    private IOdrPhoneNoteWebService odrPhoneNoteWebService;


    /**
     * 到列表页面
     */
    @RequestMapping(value = "/toListPage.do", method = {RequestMethod.GET})
    public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toListPage", "加载列表页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

        ModelAndView view = new ModelAndView("carloan/odrCompInfo/odrCompInfoList");

        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toListPage", "加载列表页面.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }

    /**
     * 到新增修改页面
     */
    @RequestMapping(value = "/toAddPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toAddPage", "加载新增.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

        ModelAndView view = new ModelAndView("carloan/odrCompInfo/odrCompInfoAdd");

        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toAddPage", "加载新增.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }

    /**
     * 到修改页面
     */
    @RequestMapping(value = "/toModifyPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toAddPage", "加载修改页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

        String id = request.getParameter("id");
        ModelAndView view = new ModelAndView("carloan/odrCompInfo/odrCompInfoModify");
        view.addObject("id", id);
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toAddPage", "加载修改.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }

    /**
     * 到详情页面
     */
    @RequestMapping(value = "/toDetailPage.do", method = {RequestMethod.GET})
    public ModelAndView toDetailPage(HttpServletRequest request, HttpServletResponse response) {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toDetailPage", "加载例子详细页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

        String id = request.getParameter("id");
        ModelAndView view = new ModelAndView("carloan/odrCompInfo/odrCompInfoDetail");
        view.addObject("id", id);

        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toDetailPage", " 加载例子详细页面.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }

    /**
     * 初始化列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initList(HttpServletRequest request, HttpServletResponse response) {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "initList", "加载列表页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());


        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        String searchName = request.getParameter("demo.name");
        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }

        if (StringUtils.isNotEmpty(pageSize)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }

        OdrCompInfoQC qc = new OdrCompInfoQC();
        if (StringUtils.isNotEmpty(searchName)) {
            //TODO SOMTHING
        }
        page.setCondition(qc);

        //TODO SOMETHING
        Pager pager = new Pager();//this.odrCompInfoService.searchListPage(page);
        List<OdrCompInfoVO> list = (List<OdrCompInfoVO>) pager.getResultList();
        ListPageVO<OdrCompInfoVO> listPage = new ListPageVO<OdrCompInfoVO>(list, pager.getTotalCount());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "initList", "加载列表页面.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return listPage;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "add", "新增对象.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

        String name = request.getParameter("name");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "新增成功!");
        OdrCompInfoVO entity = null;
        try {
            entity = new OdrCompInfoVO();
            //TODO ADD PARAM
            Long id = this.odrCompInfoService.add(entity);
            result.setData(id);
            BaseLogUtils.info(logger, "add", "新增数据.[id=" + id + "] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "add", "新增对象失败,name[" + name + "].", CurrentThreadContext.getCurrentUserName(), ex);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.error(logger, "add", "新增对象失败,name[" + name + "].", CurrentThreadContext.getCurrentUserName(), ex);
        }
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "add", "新增对象.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());

        return result;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/modify.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "modify", "修改对象.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

        String id = request.getParameter("id");
        String name = request.getParameter("name");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "修改成功!");
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("数据不存在!");
            BaseLogUtils.info(logger, "modify", "修改数据,主键不存在.[id=" + id + "]", CurrentThreadContext.getCurrentUserName());
            return result;
        }
        OdrCompInfoVO entity = null;
        try {
            entity = new OdrCompInfoVO();
            entity.setId(Long.valueOf(id));
            //entity.setName(name);
            //TODO ADD PARAM
            boolean success = this.odrCompInfoService.modify(entity);
            if (!success) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("修改失败!");
                BaseLogUtils.info(logger, "modify", "修改失败.[id=" + id + "] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
            }
            BaseLogUtils.info(logger, "modify", "修改成功.[id=" + id + "] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "modify", "修改对象失败,id[" + id + "].", CurrentThreadContext.getCurrentUserName(), ex);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.error(logger, "modify", "修改对象失败,id[" + id + "].", CurrentThreadContext.getCurrentUserName(), ex);
        }

        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "modify", "修改对象.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());

        return result;
    }

    /**
     * 删除数据
     */
    @RequestMapping(value = "/removeById.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "remove", "移除对象.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

        String id = request.getParameter("id");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "删除成功!");
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("主键不能为空!");
            return result;
        }
        try {
            this.odrCompInfoService.removeById(Long.valueOf(id));
            BaseLogUtils.info(logger, "removeById", "删除数据.[id=" + id + "]", CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "remove", "移除对象失败,主键[" + id + "].", CurrentThreadContext.getCurrentUserName(), ex);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.error(logger, "remove", "移除对象失败,主键[" + id + "].", CurrentThreadContext.getCurrentUserName(), ex);
        }

        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "remove", "移除对象.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());

        return result;
    }

    /**
     * 得到一条记录
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getById.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "getById", "根据主键获取对象.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

        String id = request.getParameter("id");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("主键不能为空!");
            BaseLogUtils.error(logger, "getById", "获取数据,主键不存在.[id=" + id + "]", CurrentThreadContext.getCurrentUserName());
            return result;
        }

        try {
            OdrCompInfoVO vo = this.odrCompInfoService.selectById(Long.valueOf(id));
            if (null == vo) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("数据不存在!");
                BaseLogUtils.info(logger, "getById", "获取数据,数据不存在.[id=" + id + "]", CurrentThreadContext.getCurrentUserName());
            }
            result.setData(vo);
            BaseLogUtils.info(logger, "getById", "获取数据.[id=" + id + "]", CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "getById", "根据主键获取对象失败,主键[" + id + "].", CurrentThreadContext.getCurrentUserName(), ex);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.error(logger, "getById", "根据主键获取对象失败,主键[" + id + "].", CurrentThreadContext.getCurrentUserName(), ex);
        }

        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "getById", "根据主键获取对象.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());

        return result;
    }

    /**
     * 获取车汇达数据列表
     *
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getChdDataList.do", method = RequestMethod.GET)
    public DataResultVO getChdDataList(HttpServletRequest request, HttpServletResponse response) {
        DataResultVO result = new DataResultVO(1, "获取车汇达数据列表");
        String compNm = request.getParameter("compNm");
        String prnCd = request.getParameter("prnCd");
        String cyCd = request.getParameter("cyCd");
        String page = request.getParameter("page");
        String pageSize = request.getParameter("pageSize");
        String dataStatus = request.getParameter("dataStatus");
        String isConnected = request.getParameter("isConnected");
        String intention = request.getParameter("intention");
        String isCanVisitor = request.getParameter("isCanVisitor");
        String usrId = request.getParameter("usrId");//电销专员的usrId
        try {
            Long currentUserId = CurrentThreadContext.getCurrentUserId();
            if (StringUtils.isEmpty(currentUserId)) {
                result.setSuccess(0);
                result.setInfo("当前用户ID为空！");
                return result;
            }
            UserDTO sysUsrDTO = (UserDTO)CurrentThreadContext.getValue(CurrentThreadContext.CURRENT_USER_INFO);
            List<SysUsrFunAuthRDTO> usrFunAuthRDTOList = sysUsrDTO.getSysUsrFunAuthRDTOList();


            if (StringUtils.isEmpty(page)) {
                page = "1";
            }
            if (StringUtils.isEmpty(pageSize)) {
                pageSize = "30";
            }

            Pager pager = new Pager();
            //判断是否是主管（电销）

            //如果是主管（能查看的数据为 未分配的公司 和 已分配的相关渠道信息 ）
            BaseLogUtils.info(logger, "", "当前用户是管理员！");
            OdrCompInfoQC condition = new OdrCompInfoQC();
            condition.setDataStatus(dataStatus);
            condition.setIsDel(0);
            condition.setCompNm(compNm);
            condition.setDataSource("CHD");
            condition.setPrnCd(prnCd);
            condition.setCyCd(cyCd);
            condition.setGktsNotMoreThan("10");
            List<String> dataStatusList = new ArrayList<>();
            dataStatusList.add("2");
            condition.setDataStatusList(dataStatusList);
            if (StringUtils.isNotEmpty(isCanVisitor)) {
                String[] s = isCanVisitor.split("_");
                List<String> strings = Arrays.asList(s);
                condition.setIsCanVisitors(strings);
            }
            if (StringUtils.isNotEmpty(isConnected)) {
                String[] s = isConnected.split("_");
                List<String> isConnecteds = Arrays.asList(s);
                condition.setIsConneceds(isConnecteds);
            }
            if (StringUtils.isNotEmpty(intention)) {
                String[] s = intention.split("_");
                List<String> strings = Arrays.asList(s);
                condition.setIntentions(strings);
            }
            pager.setCondition(condition);
            pager.setCurrentPage(Integer.valueOf(page));
            pager.setEveryPage(Integer.valueOf(pageSize));
            BaseLogUtils.info(logger, "", "查询电话拜访记录列表信息 参数为：【 " + JSONObject.toJSONString(pager) + " 】");
            pager = odrCompInfoService.selectListForPhoneNotePage(pager);
            //setIsConnectedStatus(pager);
            result.setSuccess(1);
            result.setData(pager);
        } catch (Exception e) {
            e.printStackTrace();
            result.setSuccess(0);
            result.setInfo("服务异常！");
        }
        return result;
    }


    /**
     * 获取对象和接通状态到列表中
     *
     * @param pager
     */
    /*private void setIsConnectedStatus(Pager pager) {
        List<OdrCompInfoDTO> resultList = (List<OdrCompInfoDTO>) pager.getResultList();
        if (CollectionUtils.isNotEmpty(resultList)) {
            List<Long> compIds = new ArrayList<>();
            for (OdrCompInfoDTO odrCompInfoDTO : resultList) {
                compIds.add(odrCompInfoDTO.getId());
            }
            if (CollectionUtils.isNotEmpty(compIds)) {
                OdrPhoneNoteQC odrPhoneNoteQC = new OdrPhoneNoteQC();
                odrPhoneNoteQC.setCompIds(compIds);
                odrPhoneNoteQC.setIsDel(0);
                List<OdrPhoneNoteDTO> odrPhoneNoteDTOS = odrPhoneNoteApiService.selectList(odrPhoneNoteQC);
                if (CollectionUtils.isNotEmpty(odrPhoneNoteDTOS)) {
                    for (OdrCompInfoDTO odrCompInfoDTO : resultList) {
                        for (OdrPhoneNoteDTO odrPhoneNoteDTO : odrPhoneNoteDTOS) {
                            if (odrCompInfoDTO.getId().equals(odrPhoneNoteDTO.getCompId())) {
                                odrCompInfoDTO.setIsConneced(odrPhoneNoteDTO.getIsConneced());
                            }
                        }
                    }
                }
                OdrCompChannelQC odrCompChannelQC = new OdrCompChannelQC();
                odrCompChannelQC.setCompIds(compIds);
                odrCompChannelQC.setIsDel(0);
                List<OdrCompChannelDTO> odrCompChannelDTOS = odrCompChannelApiService.selectList(odrCompChannelQC);
                if (CollectionUtils.isNotEmpty(odrCompChannelDTOS)) {
                    List<Long> channelIds = new ArrayList<>();
                    for (OdrCompChannelDTO odrCompChannelDTO : odrCompChannelDTOS) {
                        if (!channelIds.contains(odrCompChannelDTO.getChannelId())) {
                            channelIds.add(odrCompChannelDTO.getChannelId());
                        }
                    }
                    OdrChannelInfoQC odrChannelInfoQC = new OdrChannelInfoQC();
                    odrChannelInfoQC.setIds(channelIds);
                    odrChannelInfoQC.setIsDel(0);
                    List<OdrChannelInfoDTO> odrChannelInfoDTOS = odrChannelInfoApiService.selectList(odrChannelInfoQC);
                    Map<Long, OdrChannelInfoDTO> channelInfoDTOHashMap = new HashMap<>();
                    Map<Long, Long> compChannelDTOHashMap = new HashMap<>();

                    if (CollectionUtils.isNotEmpty(odrChannelInfoDTOS)) {
                        List<Long> chdChannelIds = new ArrayList<>();
                        for (OdrChannelInfoDTO odrChannelInfoDTO : odrChannelInfoDTOS) {
                            if (String.valueOf(odrChannelInfoDTO.getId()).startsWith("20191150")) {
                                channelInfoDTOHashMap.put(odrChannelInfoDTO.getId(), odrChannelInfoDTO);
                                chdChannelIds.add(odrChannelInfoDTO.getId());
                            }
                        }

                        for (OdrCompChannelDTO odrCompChannelDTO2 : odrCompChannelDTOS) {
                            if (chdChannelIds.contains(odrCompChannelDTO2.getChannelId())) {
                                compChannelDTOHashMap.put(odrCompChannelDTO2.getCompId(), odrCompChannelDTO2.getChannelId());
                            }
                        }
                        for (OdrCompInfoDTO odrCompInfoDTO : resultList) {
                            odrCompInfoDTO.setOdrChannelInfoDTO(channelInfoDTOHashMap.get(compChannelDTOHashMap.get(odrCompInfoDTO.getId())));
                        }
                    }
                }
            }
        }
    }*/

    /**
     * 分配渠道给电销专员
     */
    @RequestMapping(value = "/distribute.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object distribute(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "modify", "修改对象.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

        String ids = request.getParameter("ids");//分配给的那个人的ID
        String usrId = request.getParameter("usrId");//分配给的那个人的ID
        String isCxfp = request.getParameter("isCxfp");//是否是重新分配
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "分配成功!");
        if (StringUtils.isEmpty(ids)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("请先选择您要分配的渠道!");
            BaseLogUtils.info(logger, "modify", "分配数据,主键不存在.[usrId=" + usrId + "]", CurrentThreadContext.getCurrentUserName());
            return result;
        }
        if (StringUtils.isEmpty(usrId)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("请选择电销人员!");
            BaseLogUtils.info(logger, "modify", "分配数据,主键不存在.[usrId=" + usrId + "]", CurrentThreadContext.getCurrentUserName());
            return result;
        }
        OdrCompInfoDTO entity = null;
        String[] s = ids.split("_");
        List<Long> idList = new ArrayList<>();
        for (String s1 : s) {
            idList.add(Long.valueOf(s1));
        }
        BaseLogUtils.info(logger, "", "需要分配的渠道id 集合为：" + JSONObject.toJSONString(ids));
        try {
            entity = new OdrCompInfoDTO();
            entity.setCrtUsrId(Long.valueOf(usrId));
            entity.setIds(idList);
            boolean success = false;
            if ("1".equals(isCxfp)) {
                success = this.odrCompInfoService.batchmodify(entity);
            } else {
                success = odrCompInfoService.batchmodifyNotFp(entity);//分配未分配的
                BaseLogUtils.info(logger, "", "分配未分配的 batchmodifyNotFp");
            }
            if (!success) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("分配失败!");
                BaseLogUtils.info(logger, "modify", "分配失败.[id=" + usrId + "] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
            }
            BaseLogUtils.info(logger, "modify", "分配成功.[id=" + usrId + "] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "modify", "分配对象失败,id[" + usrId + "].", CurrentThreadContext.getCurrentUserName(), ex);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.error(logger, "modify", "分配对象失败,id[" + usrId + "].", CurrentThreadContext.getCurrentUserName(), ex);
        }

        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "modify", "分配对象.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());

        return result;
    }
}

